package route

import (
	"gitee.com/liuyun-luo/MagicStreamMovies/Server/controller"
	"gitee.com/liuyun-luo/MagicStreamMovies/Server/middleware"
	"github.com/gin-gonic/gin"
)

// 设置电影相关操作的路由
func SetupMoviesRouter(r *gin.Engine) {
	movies := r.Group("/api/v1")
	//使用游标分页获取电影
	movies.GET("/movies", controller.GetMoviesByCursor)

	//添加中间件
	movies.Use(middleware.AuthMiddleWare())
	{
		//获取指定的一部电影--看电影
		movies.GET("/movies/:movie_id", controller.GetMovie)

		//添加一部电影
		movies.POST("/movies", controller.AddMovie)

		//删除指定的一部电影
		movies.DELETE("/movies/:movie_id", middleware.AdminAuthentication(), controller.DeleteMovice)

		//给电影添加评论
		movies.POST("/movies/:movie_id/reviews", controller.AddMovieReview)

		//获取指定电影评论
		movies.GET("/movies/:movie_id/reviews", controller.GetMovieReview)

		//点赞电影
		movies.POST("/movies/:movie_id/likes", controller.LikeMovie)

		//管理员添加电影评论
		movies.PATCH("/movies/:imdb_id/admin_comment", middleware.AdminAuthentication(), controller.AdminReviewUpdate)

		// 根据管理员的评论，为用户推荐电影
		movies.GET("/movies/admin_recommend", controller.GetRecommendedMovies)
	}
}
